/*
   Copyright 2010, e-TAT

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
   
   This is a Test User Interface meant for demo purposes.
 */
window.addEvent('domready', function() {
	if ($('type') && $('edit-question-form')) {
		var type = $('type').value;
		if (type == 'radio' || type == 'checkbox' || type == 'rate'
				|| type == 'dropdown') {
			showAnswers();
		}
	}
});

function change(sid,sec,num) {
	var sid = sid
	var sec = sec
	var num = num
	redirect("survey/preview.php?sid=" + sid + "&sec=" + sec + "&num=" + num);
}

function showAnswers() {
	$('answer-choices').className = '';
}

function hideAnswers() {
	$('answer-choices').className = 'invisible';
}

function showFrequency(target) {
	alert(target.value);
	$('frequency').className = '';
	$('select_date').className = 'invisible';
	$('select_day').className = 'invisible';
	$('date1').className = 'invisible';
	$('date2').className = 'invisible';
}

function showDate() {
	$('select_date').className = '';
	$('frequency').className = '';
	$('select_day').className = 'invisible';
	$('date1').className = 'invisible';
	$('date2').className = 'invisible';
}

function showDay() {
	$('select_day').className = '';
	$('frequency').className = '';
	$('select_date').className = 'invisible';
	$('date1').className = 'invisible';
	$('date2').className = 'invisible';

}

function showFixedDate() {
	$('date1').className = '';
	$('date2').className = '';
	$('select_date').className = 'invisible';
	$('select_day').className = 'invisible';
	$('frequency').className = 'invisible';

}

function showRequired() {
	$('required').className = '';
	$('create_section').className = 'invisible';

}

function showSection() {
	$('required').className = 'invisible';
	$('create_section').className = '';

}

function checkAll(num) {
	for ( var i = 1; i < num + 1; i++) {
		var check_box = 'check_' + i;
		if ($(check_box)) {
			$(check_box).checked = 'checked';
		}
		if ($(check_box) && $('check_all').checked == '') {
			$(check_box).checked = '';
		}
	}
}

function uncheckAll(num) {
	for ( var i = 1; i < num + 1; i++) {
		var check_box = 'check_' + i;
		if ($(check_box)) {
			$(check_box).checked = '';
		}
	}
}